home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / escalant / escala21.lha / escalante2.1 / src / editor / EscalanteCommands.h < prev    next >
C/C++ Source or Header  |  1993-07-15  |  7KB  |  382 lines

  1. //
  2. //    Copyright (C) 1993  Jeff McWhirter
  3. //
  4. #ifndef DRAWCOMMANDS_H
  5. #define DRAWCOMMANDS_H
  6.  
  7. #include    "EscalanteGlobal.h"
  8.  
  9.  
  10. #include "Command.h"
  11. #include "CommonGfx.h"
  12. #include "Set.h"
  13.  
  14. #include "Alert.h"
  15. class BaseEscalanteView;
  16. class EscalanteView;
  17. class PtsGfx;
  18. class VRelation;
  19. class VGraphElement;
  20. class VEntity;
  21.  
  22.  
  23.  
  24.  
  25. class GroupPicker :public Command{
  26. public:
  27.     bool newgroup;
  28.     class Class * cl;
  29.     BaseEscalanteView * view;
  30.     GroupPicker(BaseEscalanteView * v,bool newg = TRUE,class Class * cl =0);
  31.     Command *TrackMouse(TrackPhase, Point, Point, Point);
  32. };
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44. class EscalanteCommand: public Command{
  45. public:
  46. bool dopoint;
  47. BaseEscalanteView * view;
  48. EscalanteCommand(BaseEscalanteView * v = 0){view = v;dopoint = TRUE;}
  49. void TrackConstrain(Point, Point, Point *np);
  50. Point DoPoint(Point p);
  51. };
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58. class MultiVCommand: public EscalanteCommand{
  59. public:
  60. bool doall;
  61. MultiVCommand(BaseEscalanteView * v = 0,bool all = FALSE):EscalanteCommand(v){doall = all;}
  62. };
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72. enum MoverFlags{ eMCDoneFirst = BIT(eCmdLast+1)};
  73.  
  74.  
  75. class MoverCommand : public MultiVCommand{
  76. public:
  77. Point lastP;
  78. bool h_or_v;
  79. Object * obj;
  80.     
  81. int HOrVType;
  82. Rectangle rect;
  83. Point doitdelta;
  84. Point delta;
  85. MoverCommand(Object * o,BaseEscalanteView * v = 0, bool all = FALSE,bool horvert = FALSE):MultiVCommand(v,all){
  86.     obj = o;
  87.     if(obj) obj->AddObserver(this);
  88.     lastP = gPoint0;
  89.     DoneFirst(FALSE);
  90.     h_or_v = horvert;
  91.     SetName("Move");
  92.     doitdelta = gPoint0;
  93.     delta = gPoint0;
  94.  
  95. //0 ->any move, 1 -> hor, 2 = vert
  96.     HOrVType =0;
  97. }
  98. ~MoverCommand(){
  99.     if(obj) obj->RemoveObserver(this);
  100. }
  101.  
  102. void    DoObserve(int id, int part, void *d , Object *op);
  103.  
  104. Command *TrackMouse(TrackPhase, Point, Point, Point);
  105. bool OkToMoveBy(Point & deltaP, Point np);
  106. bool OkToMoveTo(Point &np, int coarse = 1);
  107.  
  108. bool DoneFirst() {return TestFlag(eMCDoneFirst);}
  109. void DoneFirst(bool b) { SetFlag(eMCDoneFirst,b);}
  110.  
  111. virtual  void MoveBy(Point){}
  112. void DoIt();
  113. void UndoIt();
  114.  
  115. };
  116.  
  117.  
  118.  
  119.  
  120.  
  121. class RectDrawer :public MoverCommand{
  122. public:
  123. RectDrawer(BaseEscalanteView * v):MoverCommand(0,v){}
  124. Command *TrackMouse(TrackPhase, Point, Point, Point);
  125. };
  126.  
  127.  
  128. class JointMover: public MoverCommand {
  129. int jix;
  130. public:
  131. JointMover( VGraphElement * e, 
  132.        int ix,
  133.        BaseEscalanteView * view = 0,
  134.        bool all = FALSE,
  135.        bool hv = FALSE):     MoverCommand((Object*)e,view,all,hv){
  136.            jix = ix;
  137.            SetName("Move Joint");
  138.        }
  139.  
  140. Command *TrackMouse(TrackPhase, Point, Point, Point);
  141. void MoveBy(Point);
  142. };
  143.  
  144.  
  145.  
  146.  
  147. class ElementMover: public MoverCommand {
  148. public:
  149. ElementMover(VGraphElement * pe,
  150.          BaseEscalanteView * view = 0,
  151.          bool all = FALSE,
  152.          bool hv = FALSE):     MoverCommand((Object*)pe,view,all,hv){
  153.                  SetName("Move");
  154.              }
  155. Command *TrackMouse(TrackPhase, Point, Point, Point);
  156. void MoveBy(Point);
  157.  
  158. };
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165. class GfxStretcher: public MoverCommand {
  166. int ptix;
  167. public:
  168. GfxStretcher(PtsGfx* pg,
  169.          int pix,
  170.          BaseEscalanteView * view = 0,
  171.          bool all = FALSE): MoverCommand((Object*)pg,view,all){
  172.              ptix = pix;
  173.              dopoint = FALSE;
  174.              SetName("Gfx Stretch");
  175.          } 
  176.  
  177. Command *TrackMouse(TrackPhase, Point, Point, Point);
  178. void MoveBy(Point);
  179. };
  180.  
  181.  
  182.  
  183. class GfxMover: public MoverCommand {
  184. public:
  185. GfxMover(PtsGfx* g,
  186.      BaseEscalanteView * view = 0,
  187.      bool all = FALSE):MoverCommand((Object*)g,view,all){
  188.          dopoint = FALSE; 
  189.          SetName("Gfx Move");
  190. }
  191. Command *TrackMouse(TrackPhase, Point, Point, Point);
  192. void MoveBy(Point);
  193. };
  194.  
  195.  
  196.  
  197.  
  198. class EltStretcher: public MoverCommand {
  199. LocPt lp;
  200. Rectangle r;
  201. bool ds;
  202. public:
  203.  
  204. EltStretcher(VGraphElement * elt,
  205.          LocPt  p =  cLPNull,
  206.          BaseEscalanteView * view = 0,
  207.          bool all = FALSE,
  208.          bool doublestretch = FALSE,
  209.          bool hv = FALSE):MoverCommand((Object*)elt,view,all,hv) {
  210.             r= gRect0;
  211.             lp =p; 
  212.             ds = doublestretch;
  213.             SetName("Reshape");
  214. }
  215.  
  216. Command *TrackMouse(TrackPhase, Point, Point, Point);
  217.  
  218. void MoveBy(Point);
  219.  
  220. };
  221.  
  222.  
  223.  
  224.  
  225.  
  226. class Rotator: public MultiVCommand {
  227. VGraphElement * elt;
  228. public:
  229.     Rotator(VGraphElement * pe,
  230.         BaseEscalanteView * view = 0,
  231.         bool all = FALSE):MultiVCommand(view,all){elt = pe;}
  232.  
  233.     Command *TrackMouse(TrackPhase, Point, Point, Point);
  234. };
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241. class GraphCommand: public MoverCommand{
  242. public:
  243. class  VGraphElement * vgraph;
  244. GraphCommand(VGraphElement * vg,
  245.          BaseEscalanteView * view = 0):MoverCommand(0,view){vgraph = vg;}
  246. };
  247.  
  248.  
  249. class QuickMover: public MoverCommand {
  250. bool  firstrelease;
  251. Point p;
  252. public:
  253. QuickMover(VGraphElement * pe,
  254.        Point pt,
  255.        BaseEscalanteView * view = 0,
  256.        bool all = FALSE):MoverCommand((Object*)pe,view,all){
  257.            p = pt;
  258.            firstrelease = FALSE;
  259.            SetFlag(eCmdMoveEvents);
  260. }
  261. Command *TrackMouse(TrackPhase, Point, Point, Point);
  262. void MoveBy(Point);
  263. };
  264.  
  265.  
  266.  
  267. class DeleterAdder :public GraphCommand{
  268. public:
  269.     Set sset;
  270.     Set vset;
  271.     bool state;
  272.     DeleterAdder(VGraphElement * vg,
  273.              BaseEscalanteView * view):GraphCommand(vg,view){
  274.                  state = TRUE;
  275.          }
  276.     ~DeleterAdder();
  277.     void    DoObserve(int id, int part, void *d , Object *op);
  278.     void Init();
  279.     Command *TrackMouse(TrackPhase, Point, Point, Point);
  280. };
  281.  
  282.  
  283.  
  284. class EltAdder :public DeleterAdder{
  285. public:
  286.     EltAdder(VGraphElement * vg,BaseEscalanteView * view):DeleterAdder(vg,view){
  287.         SetName("Add");
  288.     }
  289.     void DoIt();
  290.     void UndoIt();
  291.     void Commit();    
  292.     void SaveElements();
  293. };
  294.  
  295.  
  296. class ElementDeleter :public DeleterAdder{
  297. public:
  298.     ElementDeleter(VGraphElement * vg,BaseEscalanteView * view):DeleterAdder(vg,view){
  299.         SetName("Delete");
  300.     }
  301.  
  302.     void DoIt();
  303.     void UndoIt();
  304.     void Commit();    
  305. };
  306.  
  307.  
  308.  
  309. #define  RelationAdder_BASE EltAdder
  310. class RelationAdder: public EltAdder {
  311. public:
  312. class VRelation * rel;
  313. bool  firstrelease;
  314. bool hadrelease;
  315. RelationAdder(class VRelation * vr,VGraphElement * vg,BaseEscalanteView * view = 0);
  316. Command *TrackMouse(TrackPhase, Point, Point, Point);
  317. Command * StoppedAdding();
  318. };
  319.  
  320.  
  321. #define  ElementAdder_BASE EltAdder
  322. class ElementAdder: public EltAdder {
  323. public:
  324. class VGraphElement * elt;
  325. bool  firstrelease;
  326. bool hadrelease;
  327.     ElementAdder(class VGraphElement * vg,VGraphElement * vg,BaseEscalanteView * view = 0);
  328.     Command *TrackMouse(TrackPhase, Point, Point, Point);
  329. };
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338. #define  MultiAdder_BASE EltAdder
  339. class MultiAdder: public EltAdder {
  340. public:
  341. int done;
  342. class VGraphElement * proto;
  343. MultiAdder(class VGraphElement * prototype,VGraphElement * vg,BaseEscalanteView * view = 0);
  344. Command *TrackMouse(TrackPhase, Point, Point, Point);
  345. };
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352. #define EltSetter_BASE GraphCommand 
  353. class EltSetter: public GraphCommand {
  354. class VRelation * rel;
  355. bool  firstrelease;
  356. bool tail;
  357. class Class * c;
  358. public:
  359.     EltSetter(class VRelation * vr,bool tl, VGraphElement * vg,class Class *cl  =0,BaseEscalanteView * view = 0);
  360.     Command *TrackMouse(TrackPhase, Point, Point, Point);
  361. };
  362.  
  363.  
  364.  
  365.  
  366. class HeadSetter: public EltSetter {
  367. public:
  368.     HeadSetter(class VRelation * vr, VGraphElement * vg, class Class *cl  =0,BaseEscalanteView * view = 0):EltSetter(vr,FALSE,vg,cl,view){}
  369. };
  370.  
  371. class TailSetter: public EltSetter {
  372. public:
  373.     TailSetter(class VRelation * vr, VGraphElement * vg,class Class *cl  =0, BaseEscalanteView * view = 0):EltSetter(vr,TRUE,vg,cl,view){}
  374. };
  375.  
  376.  
  377.  
  378.  
  379.  
  380. #endif  DRAWCOMMANDS_H
  381.  
  382.